/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kn.cstf2.users.Sql;

/**
 *
 * @author user1
 */
public class UsersSql {
    
     public static final String SELECCIONAR_USERS_SAMENAME_SAMEEMAIL;
     public static final String SELECCIONAR_USERS_BYNAME;
     public static final String SELECCIONAR_USERS_INFO;
     public static final String ACTUALIZA_DATOS_USUARIO_BYBEAN;
     public static final String BORRA_DEPENDENCIAS_ALUSUARIO;
     public static final String BORRA_ALUSUARIO;
     public static final String GUARDA_NUEVO_USUARIO;
     public static final String SAVE_NUEVO_USUARIO;
     public static final String MODIFICAR_USUARIO;


     static {
        StringBuilder qryBuilder = new StringBuilder();
        qryBuilder.append("SELECT username FROM t_users WHERE username = ? OR email = ? ");
        SELECCIONAR_USERS_SAMENAME_SAMEEMAIL = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append("SELECT * FROM t_users WHERE username like ? ");
        SELECCIONAR_USERS_BYNAME = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append("SELECT * FROM t_users WHERE id = ? ");
        SELECCIONAR_USERS_INFO = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" UPDATE t_users SET username = ?, pwd = ?, email = ?, usertype = ?, "
                + " rg = ?, rgro = ?, rco = ?, rcoro = ?, ccr = ?, ccrro = ?, opc = ?, opcro = ?, "
                + " mng = ?, mngro = ?, su = ? WHERE id = ? ");
        ACTUALIZA_DATOS_USUARIO_BYBEAN = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" DELETE FROM joinusertransition WHERE iduser = ? ");
        BORRA_DEPENDENCIAS_ALUSUARIO = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" DELETE FROM t_users WHERE id = ? ");
        BORRA_ALUSUARIO = qryBuilder.toString();
        
        
        qryBuilder = new StringBuilder();
        qryBuilder.append("INSERT INTO t_users (username, pwd, email, su, transition, transitionaccess,"
                + " implementation, implementationaccess, cop, copaccess) "
                + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
        SAVE_NUEVO_USUARIO = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append(" INSERT INTO t_users (username, pwd, email, usertype, rg, rgro, rco, rcoro, ccr, ccrro, "
                + "opc, opcro, mng, mngro, su ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
        GUARDA_NUEVO_USUARIO = qryBuilder.toString();
        
        qryBuilder = new StringBuilder();
        qryBuilder.append("UPDATE t_users SET username = ?, pwd = ?, email = ?, su = ?, transition = ?,"
                + "transitionaccess = ?, implementation = ?, implementationaccess = ?, cop = ?, copaccess = ? WHERE id = ?");
        MODIFICAR_USUARIO = qryBuilder.toString();
    }
        
}
